package com.example.husbandry_online.view;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.husbandry_online.MainActivity;
import com.example.husbandry_online.R;
import com.example.husbandry_online.adapter.ImageAdapter;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.CircleIndicator;

import java.util.ArrayList;
import java.util.List;
import java.util.zip.Inflater;


public class HusbandryFragment extends Fragment {
    Banner banner ;
    List<Integer> datas;
    View root;

    public HusbandryFragment() {
        datas = new ArrayList<>();
        datas.add(R.drawable.test1);
        datas.add(R.drawable.pig1);
        datas.add(R.drawable.pig2);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        root = inflater.inflate(R.layout.fragment_husbandry,container,false);
        banner = root.findViewById(R.id.banner);
        useBanner();
        return root;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void useBanner() {
        //--------------------------简单使用-------------------------------
        banner.addBannerLifecycleObserver(this)
                .setBannerRound2(50)
                .setAdapter(new ImageAdapter(datas))
                .setIndicator(new CircleIndicator(getContext()));
    }
}

